home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_06 / letters / checksum.c < prev   
Text File  |  1994-03-31  |  1KB  |  34 lines

  1. @CSOURCE6 = // Short example to demonstrate principles discussed<R>
  2. // Note : *'_ signals a Nassi-Schneidermann statement<R>
  3. <R>
  4. s<%-3>Sample_data *psSampleData; // pntr to sample data struct<%0><R>
  5. int iErrCode;  // return code from sampling routine<R>
  6. //*'_C getch - read the reply from the keyboard<R>
  7. char cReply = getch();<R>
  8. //*'_I Does the operator want another sample<R>
  9. if (toupper(cReply) == 'Y') {<R>
  10.     //*'_Y Continue, read another sample, etc<R>
  11.     p<%-2>sSampleData = psSampleData; // init pntr to buffe<%0>r<R>
  12.     //*'_C GetNextSample - read another sample<R>
  13.     iErrCode = GetNextSample(psSampleData);<R>
  14. END_if<R>
  15. else {<R>
  16.     //*'_N Terminate the process<R>
  17.     iErrCode = 0;<R>
  18. END_else<R>
  19. //*'_Endif Does the operator want another sample<R>
  20. //*'_CS What was the return code (from GetNextSample)<R>
  21. switch (iErrCode) {<R>
  22.     //*'_0 Return code = 0, finished with samples<R>
  23.     case SMPL_DONE :<R>
  24.     break;<R>
  25.     //*'_1 Everything OK, store sample<R>
  26.     case SMPL_OK :<R>
  27.     break;<R>
  28.     //*'_9 Default! Abort sample process<R>
  29.     default :<R>
  30.     break;<R>
  31. END_switch<R>
  32. /<%-4>/*'_Endcase What was the return code (from GetNextSample)<%0>
  33.  
  34.